package com.hrt.test.serial;

import java.io.IOException;
import java.io.OutputStream;

import com.hrt.serial.modbus.ModbusRequestModel;

public class AskDataTask extends Thread {

    private OutputStream out;

    public AskDataTask(OutputStream out) {
        this.out = out;
    }

    @Override
    public void run() {
        ModbusRequestModel model = new ModbusRequestModel();
        model.setMn("1");
        model.setDataLength(10);
        model.setStartAddr(0);

        try {
            while (true) {
                sleep(1000);
                out.write(model.getSendByte());
                out.flush();
            }

        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
        }
    }
}
